package com.sskj.tibi.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.lib.util.PopUtil;
import com.sskj.tibi.bean.WithdrawBalanceBean;
import com.sskj.tibi.bean.WithdrawRechargeCoinBean;
import com.sskj.tibi.http.HttpConfig;
import com.sskj.tibi.ui.activity.WithdrawActivity;

import java.util.List;


public class WithdrawActivityPresenter extends BasePresenter<WithdrawActivity> {

    public void getBalance(String code) {
        httpService.getBalance(code)
                .execute(new JsonCallBack<HttpData<WithdrawBalanceBean>>() {
                    @Override
                    public void onSuccess(Response<HttpData<WithdrawBalanceBean>> response) {
                        HttpData<WithdrawBalanceBean> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.updateUI(httpData.getData());
                        }
                    }
                });
    }

    public void coinList() {
        httpService.coinList()
                .execute(new JsonCallBack<HttpData<List<WithdrawRechargeCoinBean>>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<List<WithdrawRechargeCoinBean>>> response) {
                        HttpData<List<WithdrawRechargeCoinBean>> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {

                            mView.updateCoinList(httpData.getData());
                        }
                    }
                });
    }

    public void withdraw(String address, String money, String wall_code, String payment_password, String google_code, String code) {
        httpService.withdraw(address, money,wall_code,payment_password,google_code,code)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData httpData = response.body();
                        ToastUtil.showShort(httpData.getMsg());
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.withdrawSuccess();
                        }
                    }
                });
    }
}
